package com.fdb.efp.console.api.rest;

import com.fdb.basic.framework.core.constant.ResponseData;
import com.fdb.basic.framework.web.controller.AbstractController;
import com.fdb.efp.console.service.facade.LoanRepayPlanService;
import com.fdb.efp.console.service.vo.LoanRepayPlanVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
  * 还款计划
  * @author qiuyf
  * @since 2019年2月16日 下午4:36:16
  * @version 1.0
 */
@RestController
@RequestMapping("/api")
public class LoanRepayPlanController extends AbstractController {

	@Autowired
	@Qualifier("accLoanRepayPlanService")
	private LoanRepayPlanService accLoanRepayPlanService;
	
	@RequestMapping(value = "/loan/repay/plan", method = RequestMethod.POST)
	public @ResponseBody ResponseData<List<LoanRepayPlanVO>> queryLoanRepayPlan(@RequestBody LoanRepayPlanVO vo) {
		List<LoanRepayPlanVO> outputVo = accLoanRepayPlanService.qryLoanRepayPlanByLoanNo(vo);
		outputVo.forEach(item -> 
			item.setPrdName(vo.getPrdName())
		);
		return getResponseData(outputVo);

	}

	/**
	 * 查询还款计划（排除已缩期的） <br>
	 * 0.1:wanglaisheng:2020年11月23日 :新增 <br>
	 *
	 * @author wanglaisheng
	 * @since 2020年11月23日
	 * @date 2020年11月23日
	 * @version 0.1
	 * @param vo
	 * @return
	 */
	@RequestMapping(value = "/loan/repay/planNew", method = RequestMethod.POST)
	public @ResponseBody ResponseData<List<LoanRepayPlanVO>> queryLoanRepayPlanNewByPage(@RequestBody LoanRepayPlanVO vo) {
		List<LoanRepayPlanVO> outputVo = accLoanRepayPlanService.getPlanByPKWithoutCancelStatusByPage(vo);
		outputVo.forEach(item ->
				item.setPrdName(vo.getPrdName())
		);
		return getResponseData(outputVo);

	}
}
